<?php

namespace App\Admin\Controllers\Invoicing;


use App\Admin\Actions\Grid\Row\SwtProcurement\CompleteReplenishment;
use App\Admin\Actions\Grid\Row\SwtProcurement\EmployeeDetail;
use App\Admin\Actions\Grid\Row\SwtProcurement\ProcurementDetail;
use App\Admin\Actions\Grid\Row\SwtProcurement\ReplenishmentDetail;
use App\Admin\Actions\Grid\Row\SwtProcurement\StartProcurement;
use App\Admin\Actions\Grid\Row\SwtProcurement\StartReplenishment;
use App\Admin\Actions\Grid\Tools\SwtProcurement\MakeInbound;
use App\Admin\Renderable\EmployeeRenderable;
use App\Admin\Renderable\GoodsRenderable;
use App\Admin\Renderable\MachineRenderable;
use App\Admin\Repositories\SwtGood;
use App\Admin\Repositories\SwtReplenishment;
use App\Models\SwtEmployee;
use App\Models\SwtMachine;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Http\Controllers\AdminController;
use Ramsey\Uuid\Uuid;

class SwtEmployeeController extends AdminController
{
    protected $title = '员工管理';

    /**
     * 查看采购单列表
     * return
     */
    protected function grid()
    {
        return Grid::make(new SwtEmployee(), function (Grid $grid) {

            $grid->column('id')->sortable();
            $grid->column('name','员工姓名');
            $grid->column('type','员工身份')->using(['无身份','采购员','补货员'])->label(['danger','info','success']);


            $grid->column('created_at');

            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal('name','员工姓名');
                $filter->between('created_at');
            });

            $grid->actions(function (Grid\Displayers\Actions $actions) {
                //采购单详情按钮
                $actions -> prepend(new EmployeeDetail());

            });

            $grid->quickSearch('name');
            $grid->disableCreateButton(false);

        });
    }



    /**
     * 查看采购单详情
     * return
     */
    protected function form()
    {
        return Form::make(new SwtEmployee(), function (Form $form) {

            $form->text('name','员工姓名');
            $form->text('contact','联系方式');
            $form->select('type','员工身份')->options([1=>'采购员',2=>'补货员']);


        });
    }

}
